<template>
  <img @error="onError" :src="getSrc(props.src)" />
</template>

<script setup>
import { getImageUrl } from '@/kang/js/utils'
import defaultGroup from '@/kang/img/default_group.png'

const props = defineProps(['src'])

function getSrc(src = '') {
  if (src) {
    if (src.includes('kang')) {
      return getImageUrl(src.split('/').pop().split('.')[0])
    } else {
      return src
    }
  } else {
    return ''
  }
}

function onError(e) {
  e.target.src = defaultGroup
}
</script>

<style lang="scss" scoped></style>
